package oop2;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class TestJavaClass {
    public static void main(String[] args) {
        JavaClass2 j=new JavaClass2();
        j.name="java79";
        j.dirTeacher="老李";
        Scanner in=new Scanner(System.in);
        int choice=0;
        while (true){
            System.out.println("1:加新人，2：查看班级情况，3：查找，4：按照区间查找, 5:开除学生，9：退出");
            choice=in.nextInt();
            if(choice==1){
                System.out.print("请输入新生姓名：");
                String name=in.next();
                boolean addok = j.add(name);
                System.out.println(addok?"新生保存成功":"保存失败，原因可能是重名或者是位置满了。。。");
            }else if(choice==2){
                j.show();
            }else if(choice==3){
                System.out.print("找谁？");
                String name=in.next();
                boolean exist = j.search(name);
                if(exist){
                    System.out.println(name+"在这个班");
                }else{
                    System.out.println(name+"不在这个班");
                }
            }else if(choice==4){
                System.out.print("找谁？");
                String name=in.next();
                System.out.print("请输入范围：");
                int start=in.nextInt();
                int end=in.nextInt();
                boolean exist = j.search2(start,end,name);
                if(exist){
                    System.out.println(name+"在这个班");
                }else{
                    System.out.println(name+"不在这个班");
                }
            }else if(choice==5){
                System.out.print("开除谁？");
                String name=in.next();
                boolean dismiss = j.dismiss(name);
                if(dismiss){
                    System.out.println("开除成功");
                }else{
                    System.out.println("查无此人");
                }
            }else if(choice==9){
                break;
            }
        }
    }
}
